home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
ca29_3.zip
/
BBMAINT1.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-03-24
|
20KB
|
759 lines
;**** TRACE ON ; Debugging
;
; ----- COM-AND BBS UserID maintenance script (User file)
; Commenced: 11/90 R.McG
; -----------------------------------------------------------------------
; Purpose:
; The script, named BBMAINT1.CMD, produces the main window for
; UserID functions of BBMAINT, and implements its functions. It
; is not directly callable itself.
; -----------------------------------------------------------------------
; Usage:
; N99 -> Text attribute value (setup by BBMAINT.CMD)
; N98 -> BBMAINT Mainline cursor position
; N97 -> BBMAINT Mainline cursor position
; N96 -> our mainline cursor position
; N95 -> our mainline cursor position
; -----------------------------------------------------------------------
;
; This script is intended ONLY to be used for FCALL
;
IF NOT FCALLED
WOPEN 10,10,13,70 (cont) NOUSEsc
ATSAY 10,12 (cont) " BBS Users "
ATSAY 11,12 (cont) " The script: "*"_SCRIPT"
ATSAY 12,12 (cont) " is not used by itself... it is called through BBMAINT"
ATSAY 13,26 (cont) " Press any key to continue "
KEYGET S0 ; Wait for any key
WCLOSE ; Close open window
EXIT ; Terminate right here
ENDIF
GOSUB UserFile ; Invoke function
FRETURN ; Return to caller
; -----------------------------------------------------------------------
; ----- NoUser: Inform that there's no USER ID file to modify
;
NoUser:
WOPEN 10,10,13,70 (cont) NOUSEsc
ATSAY 10,12 (cont) " BBS User "
ATSAY 11,12 (cont) " The file: "*S22&"\BBS-User"
ATSAY 12,12 (cont) " does not exist. Please create subdirectories first."
ATSAY 13,26 (cont) " Press any key to continue "
;
; Wait a keypress
;
KEYGET S0 ; Wait for any key
WCLOSE
NOUSEsc:
RETURN
; -----------------------------------------------------------------------
; ----- Subroutine: UserFile -> Update user ID directory
;
UserFile:
GOSUB NewUser ; Create if not there
IF NOT ISFILE S22&"\BBS-USER"
GOSUB NoUser ; Inform there's no file
RETURN ; .. so we can't continue
ENDIF
;
; Open a window
;
WOPEN 0,0 23,79 (defa) User_Esc
ATSAY 0,2 (defa) " BBS Users "
ATSAY 23,25 (defa) " Press ESC to cancel BBMAINT "
;
; Paint the menu
;
USFI100:
CLEAR ; Clear window
LOCATE 2,2
MESS " 1) Add an ID"
MESS " 2) Delete an ID"
MESS " 3) Modify an ID's values"
MESS " 4) Print User list"
MESS " 5) View list of IDs"
MESS "──────────────────────────────────── "
MESS "Note: Alt-Q to edit a file"
MESS " Alt-F for a directory search"
MESS " Alt-F10 to shell to DOS"
MESS " "
MESS "──────────────────────────────────── "
MESS " "
MESS "Select item (carriage return = previous): "
CURSOR N96,N95 ; Read current cursor
;
; Wait for entry, and interpret
;
USFI200:
LOCATE N96 N95 ; Reposition cursor
KEYGET S0 ; Wait for it
SWITCH S0 ; Act according to keyget
CASE "1"
GOSUB AddID
ENDCASE
CASE "2"
GOSUB DelID
ENDCASE
CASE "3"
GOSUB ModID
ENDCASE
CASE "4"
GOSUB PrnID
ENDCASE
CASE "5"
GOSUB ViewID
GOTO USFI100 ; Repaint after this
ENDCASE
CASE "0d" ; c/r alone is exit
WCLOSE ; Close window...
RETURN ; and return to caller
ENDCASE
CASE "_NULL" ; ESC -> Null
WCLOSE ; Close window...
RETURN ; Leave Main routine
ENDCASE
CASE "2100" ; Alt-F
MANUAL "0x2100" ; Perform Dir cmd
ENDCASE
CASE "1000" ; Alt-Q
MANUAL "0x1000" ; Edit a file
ENDCASE
CASE "7100" ; Alt-F10
SHELL
DWINDOW 1,2,22,78; Reset dwindow after shell
LEGEND "_LEGEND" ; Redo the legend
ENDCASE
DEFAULT ; None of the above
SOUND 100,100 ; Bronx cheer
ENDCASE
ENDSWITCH
GOTO USFI200 ; Repaint screen and ask again
;
; End of Users procedure
;
User_Esc:
S0 = "" ; Fake a nulll entry
RETURN ; Leave users routine
; -----------------------------------------------------------------------
; ----- AddID: Add an ID to the User file
;
AddID:
SET FLAG(0) OFF ; Flag for ESCAPE
WOPEN 10,10,15,70 (cont) ADIDEsc
ATSAY 10,12 (cont) " BBS User Add "
ATSAY 11,12 (cont) "Enter the ID to be added: "
ATSAY 15,26 (cont) " Press ESC to cancel "
;
; Wait a keypress
;
LOCATE 11,38
GET S0 8 ; get ID
IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
LJ S0 ; Left justify
UPPER S0 ; ... and upper case
IF NULL S0 GOTO ADIDEnd ; get out on empty entry
GOSUB LkpID ; Lookup ID in User file
IF FOUND ; If its there we can't add it
WCLOSE ; Close open window
GOTO ModID_Add ; Skip if ID found
ENDIF
S10 = S0 ; Save ID
GOTO ADID100 ; And branch around parallel code
;
; Entry from ModID... Nothing to modify
;
AddID_Mod:
WOPEN 10,10,15,70 (cont) ADIDEsc
ATSAY 10,12 (cont) " BBS User Add "
ATSAY 11,12 (cont) "Enter the ID to be added: "
ATSAY 11,38 (cont) S0
ATSAY 15,26 (cont) " Press ESC to cancel "
S10 = S0 ; Copy it for remainder
;
; Ask for a password
;
ADID100:
ATSAY 12,12 (cont) "Enter the password: "
LOCATE 12,38
GET S0 8 ; get resp
IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
LJ S0 ; Left justify
UPPER S0 ; ... and upper case
IF NULL S0 ; Password MUST be filled in
SOUND 100,100 ; Indicate displeasure
GOTO ADID100 ; Try again
ENDIF
S10(8:15) = S0 ; Save password
;
; Ask for privileged flag
;
ADID200:
ATSAY 13,12 (cont) "Priveleged access (y/n): "
LOCATE 13,38
GET S0 1 ; get resp
IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
IF NULL S0 or NOT FIND "YN" S0(0)
SOUND 100,100 ; Indicate displeasure
GOTO ADID200 ; Try again
ENDIF
IF FIND "Y" S0(0) S10(16:16) = "P" ; Save priveleged access
;
; Ask for one more look
;
ADID300:
ATSAY 14,12 (cont) "OK to add this record?: "
LOCATE 14,38
GET S0 1 ; get resp
IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
IF NULL S0 or NOT FIND "YN" S0(0)
SOUND 100,100 ; Indicate displeasure
GOTO ADID300 ; Try again
ENDIF
IF FIND "N" S0(0)
WCLOSE ; Close window
GOTO AddID ; And try again
ENDIF
;
; Add comments and write the record
;
S10(17:70) = "* Added "*"_DATE"*", at "*"_TIME"
GOSUB AddUser ; Write to User file
;
; End of add procedure
;
ADIDEnd:
WCLOSE
ADIDEsc:
SET FLAG(0) ON
RETURN
;
; ----- AddUser: Add a record to the user file...
; .. S10 passes the record to be written
;
AddUser:
FOPENO S22&"\BBS-User" TEXT APPEND
IF NOT SUCCESS ; Open failed
S0 = "Error opening: "*S22&"\BBS-User"
GOSUB Error ; Report
RETURN ; And we're done
ENDIF
PRESERVE S10 ; Preserve ^'s and !'s
WRITE S10 ; Write the record
WRITE "!^Z" ; And finish it
FCLOSEO
RETURN
; -----------------------------------------------------------------------
; ----- LkpID: Lookup an ID in the BBS-User file
; .. S0 passes the ID to be tested
; .. S10 returns the record read
;
LkpID:
FOPENI S22&"\BBS-User" TEXT
IF NOT SUCCESS ; Open failed
S0 = "Error opening: "*S22&"\BBS-User"
GOSUB Error ; Report
SET FOUND OFF ; Not found
RETURN ; And we're done
ENDIF
;
; Read loop
;
LOID100:
READ S10 80 N0 ; Read a record
IF EOF GOTO LOID200 ; Skip on EOF
IF STRCMP S10(0:0) "<" GOTO LOID110
IF STRCMP S10(0:7) S0(0:7) GOTO LOID300
;
; Record longer than 80 chars
;
LOID110:
IF N0 LT 80 GOTO LOID100; If exactly 80 rtnd, c/r wasn't read
READ S10 80 N0 ; Read remainder of rec
GOTO LOID110 ; Read until less than 80
;
; We have end-of-file - not found
;
LOID200:
SET FOUND OFF ; Indicate not found
GOTO LOIDEnd
;
; We have a hit - return found
;
LOID300:
SET FOUND ON ; Indicate found
;
; And exit
;
LOIDEnd:
FCLOSEI
RETURN
; -----------------------------------------------------------------------
; ----- DelID: Delete an ID from User file
;
DelID:
SET FLAG(0) OFF ; Flag for ESCAPE
WOPEN 10,10,15,70 (cont) DEIDEsc
ATS